package com.blb.service.impl;

import com.blb.entity.Product;
import com.blb.entity.ProductAttribute;
import com.blb.entity.WareMenu;
import com.blb.mapper.ProductMapper;
import com.blb.service.IProductService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author HuaHao
 * @since 2019-11-16
 */
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService {
    @Resource
    private ProductMapper productMapper;

    @Override
    public List<Product> findAllProduct(String pName) {
        return productMapper.findAllProduct(pName);
    }

    @Override
    public void addProduct(Product product) {
        productMapper.addProduct(product);
    }

    @Override
    public void updateProduct(Product product) {
        productMapper.updateProduct(product);
    }

    @Override
    public List<Product> getMyCompanyProductInfo(List<String> ids, String companyId,int start ,int length) {
        return productMapper.getMyCompanyProductInfo(ids, companyId, start, length);
    }

    @Override
    public void addProductAttributeList(String productId, List<ProductAttribute> list) {
        productMapper.addProductAttributeList(productId,list);
    }

    @Override
    public List<ProductAttribute> findProductAttributeList(String productId) {
        return productMapper.findProductAttributeList(productId);
    }

    @Override
    public void updatePstatus(String id, String status) {
        productMapper.updatePstatus(id,status);
    }

    @Override
    public void deleteAttributeList(String productId) {
        productMapper.deleteAttributeList(productId);
    }

    @Override
    public int count(List<String> ids, String companyId) {
        System.out.println(productMapper.count(ids, companyId));
        return productMapper.count(ids, companyId);
    }


    @Override
    public List<Product> findAllOrder(int start, int length, String companyId, String orderId, String pName, String orderStatus, String dealTime) {
        return productMapper.findAllOrder(start, length, companyId, orderId, pName, orderStatus, dealTime);
    }

    @Override
    public int countOrder(String companyId, String orderId, String pName, String orderStatus, String dealTime) {
        return productMapper.countOrder(companyId, orderId, pName, orderStatus, dealTime);
    }

    @Override
    public Product findDetailOrder(String companyId, String orderId) {
        return productMapper.findDetailOrder(companyId, orderId);
    }

    @Override
    public Product findLogistics(String companyId, String orderId) {
        return productMapper.findLogistics(companyId, orderId);
    }

    /**
     * lifeng
     * 根据商品编号查看商品所有信息
     * @param pNumber
     * @return
     */
    @Override
    public Product getProductByPNumber(String pNumber) {
        return productMapper.getProductByPNumber(pNumber);
    }
    /**lifeng
     * 商品审核
     * @param pNumber
     * @param aStatus
     * @param companyId
     */
    @Override
    public void audit(String pNumber, String aStatus, String companyId) {
        productMapper.audit(pNumber,aStatus,companyId);
    }
    /**lifeng
     * 商品审核   上架状态
     * @param pNumber
     * @param aStatus
     * @param companyId
     */
    @Override
    public void audit2(String pNumber, String aStatus, String pStatus, String companyId) {
        productMapper.audit2(pNumber,aStatus,pStatus,companyId);
    }


    /**
     * 未审核数量
     * @param companyId
     * @return
     */
    @Override
    public int noAudit(String companyId) {
        return productMapper.noAudit(companyId);
    }

    /**
     * 已审核数量
     * @param companyId
     * @return
     */
    @Override
    public int yetAudit(String companyId) {
        return productMapper.yetAudit(companyId);
    }
    /**
     * lifeng
     * 未通过数量
     * @return
     */
    @Override
    public int notAudit(String companyId) {
        return productMapper.notAudit(companyId);
    }
    /**
     * lifeng
     * 通过pNumber找到商品状态
     * @param pNumber
     * @param companyId
     * @return
     */
    @Override
    public String getpStatus(String pNumber, String companyId) {
        return productMapper.getpStatus(pNumber,companyId);
    }

    @Override
    public List<WareMenu> getMenusByCompanyId(String companyId) {
        return productMapper.getMenusByCompanyId(companyId);
    }

    @Override
    public List<Map<String, Object>> getPByEnterprise(String enterprise, int start, int length) {
        return productMapper.getPByEnterprise(enterprise,start,length);
    }

    @Override
    public int countGetPByEnterprise(String enterprise) {
        return productMapper.countGetPByEnterprise(enterprise);
    }

    @Override
    public List<Map<String, Object>> getPBySupplier(String companyId, int start, int length) {
        return productMapper.getPBySupplier(companyId,start,length);
    }

    @Override
    public int countGetPBySupplier(String companyId) {
        return productMapper.countGetPBySupplier(companyId);
    }

    @Override
    public List<Map<String, Object>> getPByCompany(String companyId,int start,int length) {
        return productMapper.getPByCompany(companyId,start,length);
    }

    @Override
    public int countGetPByCompany(String companyId) {
        return productMapper.countGetPByCompany(companyId);
    }

    @Override
    public int getStockById(String productId) {
        return productMapper.getStockById(productId);
    }

    @Override
    public Map<String, Object> getProductById(String productId) {
        return productMapper.getProductById(productId);
    }

    @Override
    public int monthSale(String productId) {
        return productMapper.monthSale(productId);
    }
}
